/**
 * 
 */
package daos;

import hibernateUtils.HibernateUtil;

import java.util.List;

import loansManagement.Loan;
import loansManagement.Reservation;
import mediasManagement.Media;

import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;


/**
 * @author virgil
 *
 */
public class LoanDAO {

	@SuppressWarnings("unchecked")
	public List<Loan> findAll() {
		Session session = HibernateUtil.openSession();
		Criteria criteria = session.createCriteria(Loan.class).add(Restrictions.eq("isReturn", false));
		List<Loan> loans = criteria.list();
		return loans;
	}
	
	public List<Reservation> findAllReservations() {
		Session session = HibernateUtil.openSession();
		Query query = session.createQuery("from Reservation");
		List<Reservation> reservations = query.list();
		return reservations;
	}

}
